#ifndef _jammit_timer_h_
#define _jammit_timer_h_

#include <windows.h>
#include <stdio.h>

#include <Core\Core.h>

using namespace Upp;

typedef int64 TimerUnitType;

// Not using TimeStop class because it may not have the win precision due to POSIX compliance.
// Plus may as well support large values; who knows?
// Singleton causes heap error; converting to simple staticly instantiated class

class Timer : Moveable<Timer> {
	private:
		LARGE_INTEGER largestarttime;   // A point in time
		long long ticksPerSecond;
		long long starttime;
	public:
		Timer();
		bool withDecimals;
		TimerUnitType Elapsed() const; // Ticks, like TimeStop
		TimerUnitType ElapsedDays() const; // It could happen!
		TimerUnitType ElapsedHours() const;
		TimerUnitType ElapsedMinutes() const;
		TimerUnitType ElapsedSeconds() const;
		TimerUnitType ElapsedMilliseconds() const;
		TimerUnitType ElapsedMicroseconds() const;
		// Set the remainder flag if you want the remainder instead of the dividend
		TimerUnitType ConvertTicksToDays(TimerUnitType ticks, bool remainder = false) const;
		TimerUnitType ConvertTicksToHours(TimerUnitType ticks, bool remainder = false) const;
		TimerUnitType ConvertTicksToMinutes(TimerUnitType ticks, bool remainder = false) const;
		TimerUnitType ConvertTicksToSeconds(TimerUnitType ticks, bool remainder = false) const;
		TimerUnitType ConvertTicksToMilliseconds(TimerUnitType ticks, bool remainder = false) const;
		TimerUnitType ConvertTicksToMicroseconds(TimerUnitType ticks, bool remainder = false) const;
		String ToString() const;  // Returns seconds, milliseconds, or microseconds depending on what is most readable.  less than 1 second then milli, less than 10 milli, micro
		void Reset();
};

#endif
